package com.cadre.web.controller.officer;

import com.cadre.common.utils.R;
import com.cadre.common.utils.annotation.SysLog;
import com.cadre.common.utils.common.GenerateUUID;
import com.cadre.common.utils.oldutil.DateUtil;
import com.cadre.common.utils.oldutil.ValidatorUtils;
import com.cadre.system.domain.officer.A93;
import com.cadre.system.service.A93Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

@Api(value = "秘书经历", tags = {"秘书经历"})
@RequestMapping({"/a01/a93"})
@RestController
/* loaded from: A93Controller.class */
public class A93Controller {
    @Autowired
    private A93Service a93Service;

    @GetMapping({"/list/{personid}"})
    @ApiOperation("获取秘书经历列表")
    public R list(@PathVariable String personid) {
        return R.ok().put("data", (Object) this.a93Service.selectListByPersonid(personid));
    }

    @RequestMapping(value = {"/listforpage"}, method = {RequestMethod.POST})
    @ApiOperation(value = "获取秘书经历列表（分页）", notes = "personid:人员id,分页参数；结果集:page")
    public R listforpage(@RequestParam Map<String, Object> map) {
        return R.ok().put("page", (Object) this.a93Service.selectListforPage(map));
    }

    @GetMapping({"/info/{flowid}"})
    @ApiOperation("获取一条秘书经历")
    public R info(@PathVariable("flowid") String flowid) {
        return R.ok().put("a93", (Object) ((A93) this.a93Service.getBaseMapper().selectById(flowid)));
    }

    @PostMapping({"/save"})
    @SysLog(value = "新增秘书经历信息", target = "A01", set = "A93", type = 0)
    @ApiOperation("添加秘书经历")
    public R save(@RequestBody A93 a93) {
        a93.setFlowid(GenerateUUID.getUUID());
        try {
            if (a93.getA9301() != null) {
                Date sdate = a93.getA9301();
                sdate.setHours(10);
                a93.setA9301(sdate);
            }
        } catch (Exception e) {
        }
        try {
            if (a93.getA9302() != null) {
                Date edate = a93.getA9302();
                edate.setHours(10);
                a93.setA9302(edate);
            }
        } catch (Exception e2) {
        }
        this.a93Service.getBaseMapper().insert(a93);
        return R.ok();
    }

    @PostMapping({"/update"})
    @SysLog(value = "修改秘书经历信息", target = "A01", set = "A93", type = 1)
    @ApiOperation("秘书经历更新")
    public R update(@RequestBody A93 a93) {
        ValidatorUtils.validateEntity(a93, new Class[0]);
        try {
            if (a93.getA9301() != null) {
                Date sdate = a93.getA9301();
                sdate.setHours(10);
                a93.setA9301(sdate);
            }
        } catch (Exception e) {
        }
        try {
            if (a93.getA9302() != null) {
                Date edate = a93.getA9302();
                edate.setHours(10);
                a93.setA9302(edate);
            }
        } catch (Exception e2) {
        }
        this.a93Service.getBaseMapper().updateById(a93);
        return R.ok();
    }

    @PostMapping({"/delete"})
    @SysLog(value = "删除秘书经历信息", target = "A01", set = "A93", type = DateUtil.SUB_MONTH)
    @ApiOperation("秘书经历删除")
    public R delete(@RequestBody String[] flowids) {
        this.a93Service.getBaseMapper().deleteBatchIds(Arrays.asList(flowids));
        return R.ok();
    }
}
